//
//  CustomHeadTableViewCell.m
//  WangI
//
//  Created by dllo on 15/11/25.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "CustomHeadTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation CustomHeadTableViewCell

-(void)dealloc {
    [_labelText release];
    [_labelTitle release];
    [_imageV release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addSubview:self.imageV];
        [self addSubview:self.labelTitle];
        [self addSubview:self.labelText];
        
        [_labelTitle release];
        [_labelText release];
        [_imageV release];
        
        
    }
    return self;
}


#pragma mark -- setDataSource

- (void)setHeaderDataSource:(NSArray *)headerDataSource {
    if (_headerDataSource != headerDataSource) {
        [_headerDataSource release];
        _headerDataSource = [headerDataSource retain];
    }
    [self.imageV sd_setImageWithURL:headerDataSource[0]];
    self.labelTitle.text = headerDataSource[1];
    self.labelText.text = headerDataSource[2];
}

- (void)setRecreationDataSource:(NSArray *)recreationDataSource {
    if (_recreationDataSource != recreationDataSource) {
        [_recreationDataSource release];
        _recreationDataSource = [recreationDataSource retain];
    }
    
    [self.imageV sd_setImageWithURL:recreationDataSource[0]];
    self.labelTitle.text = recreationDataSource[1];
    self.labelText.text = recreationDataSource[2];
}

- (void)setSportDataSource:(NSArray *)sportDataSource {
    if (_sportDataSource != sportDataSource) {
        [_sportDataSource release];
        _sportDataSource = [sportDataSource retain];
    }
    
    [self.imageV sd_setImageWithURL:sportDataSource[0]];
    self.labelTitle.text = sportDataSource[1];
    self.labelText.text = sportDataSource[2];
}

- (void)setHotDataSource:(NSArray *)hotDataSource {
    if (_hotDataSource != hotDataSource) {
        [_hotDataSource release];
        _hotDataSource = [hotDataSource retain];
    }
    
    [self.imageV sd_setImageWithURL:hotDataSource[0]];
    self.labelTitle.text = hotDataSource[1];
    self.labelText.text = hotDataSource[2];
}

- (void)setFinacaDataSource:(NSArray *)finacaDataSource {
    if (_finacaDataSource != finacaDataSource) {
        [_finacaDataSource release];
        _finacaDataSource = [finacaDataSource retain];
    }
    
    [self.imageV sd_setImageWithURL:finacaDataSource[0]];
    self.labelTitle.text = finacaDataSource[1];
    self.labelText.text = finacaDataSource[2];
}


#pragma mark -- layoutSubviews

-(void)layoutSubviews {
    [super layoutSubviews];
    self.imageV.frame = CGRectMake(5, 5, self.frame.size.width / 4, self.frame.size.height - 10);
    self.labelTitle.frame = CGRectMake(self.imageV.frame.size.width + 10, 5, self.frame.size.width * 3 / 4 - 15, 30);
    self.labelText.frame = CGRectMake(self.imageV.frame.size.width + 10, self.labelTitle.frame.size.height + 10, self.labelTitle.frame.size.width, self.frame.size.height - 45);
}


#pragma mark -- private

-(UIImageView *)imageV {
    if (!_imageV) {
        self.imageV = [[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _imageV;
}

-(UILabel *)labelTitle {
    if (!_labelTitle) {
        self.labelTitle = [[UILabel alloc] initWithFrame:CGRectZero];
        _labelTitle.font = [UIFont boldSystemFontOfSize:18];
    }
    return _labelTitle;
}

-(UILabel *)labelText {
    if (!_labelText) {
        self.labelText = [[UILabel alloc] initWithFrame:CGRectZero];
        _labelText.numberOfLines = 2;
        _labelText.font = [UIFont systemFontOfSize:15];
    }
    return _labelText;
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
